home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
gfx
/
misc
/
MesaGL-tk.lha
/
src
/
awindow.c
next >
Wrap
C/C++ Source or Header
|
1998-09-21
|
29KB
|
969 lines
/*
* $Id: Awindow.c 3.00 1998/09/21 19:17:47 NielsF Exp NielsF $
*/
/*
* (c) Copyright 1993, Silicon Graphics, Inc.
* ALL RIGHTS RESERVED
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the above
* copyright notice appear in all copies and that both the copyright notice
* and this permission notice appear in supporting documentation, and that
* the name of Silicon Graphics, Inc. not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission.
*
* THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
* AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
* GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
* SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
* KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
* LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
* THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
* ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
* POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
*
* OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
/*
* $Log: Awindow.c $
* Revision 3.0 1998/09/21 19:17:47 NielsF
* bumped to mesa 3.0
*
* $Log: Awindow.c $
* Revision 1.8 1997/06/25 19:17:47 StefanZ
* bumped to mesa 2.2
*
* Revision 1.5 1996/10/07 00:18:11 StefanZ
* Mesa 2.0 Fixed
*
* Revision 1.4 1996/08/14 22:53:16 StefanZ
* rev 1.3 tk fixes was from George 'Wulf' Krämer
*
* Revision 1.3 1996/08/14 22:23:31 StefanZ
* Modified due to api change in amigaMesa
* Implemented div. Input modifier and changed windowhandling
*
* Revision 1.2 1996/06/02 00:03:03 StefanZ
* Started to use RCS to keep track of code.
*
*/
/*
* History:
*
* 1.0 960315 Now almost evetything is implemented
* 1.1 960425 Fixed problem with double closeclicks (Thanx to Daniel Jönsson)
* 1.2 960731 Modified due to api change in amigaMesa
* 1.3 Implemented div. Input modifier and changed windowhandling (Georg 'Wulf' Krämer)
*
* TODO:
* Exposefunc
*
*
*/
//#define USE_CLIP_LAYER
#undef USE_CLIP_LAYER
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <intuition/intuition.h>
#include <devices/inputevent.h>
#include <inline/exec.h>
#include <inline/intuition.h>
#include <inline/graphics.h>
#ifdef USE_CLIP_LAYER
#include <inline/layers.h>
#endif
extern struct ExecBase *SysBase;
#include <gl/gltk.h>
#include <gl/amigamesa.h>
#define static
#if defined(__cplusplus) || defined(c_plusplus)
#define class c_class
#endif
#if DBG
#define TKASSERT(x) \
if ( !(x) ) { \
PrintMessage("%s(%d) Assertion failed %s\n", \
__FILE__, __LINE__, #x); \
}
#else
#define TKASSERT(x)
#endif /*
* * DBG
*/
/*
* Some Bitmasks for amigaevents
*/
#define ControlMask (IEQUALIFIER_CONTROL)
#define ShiftMask (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT)
#define MousePressedMask (SELECTDOWN | MENUDOWN | MIDDLEDOWN)
/**********************************************************************/
struct wnd {
int x, y, width, height;
GLenum type, dmPolicy;
GLint ID;
struct amigamesa_context *context;
struct Screen *screen;
struct Window *window;
#ifdef USE_CLIP_LAYER
struct Region *clipreg;
#endif
};
struct wnd win =
{0, 0, 100, 100, TK_INDEX, 0, 0, NULL, NULL, NULL
#ifdef USE_CLIP_LAYER
,NULL
#endif
};
/*
* Local prototypes
*/
struct Region *clipWindow(struct Window *win,
LONG minX, LONG minY, LONG maxX, LONG maxY);
struct Region *clipWindowToBorders(struct Window *win);
GLboolean tkPopupEnable = TRUE;
/*
* Fixed palette support.
*/
// #define BLACK PALETTERGB(0,0,0)
// #define WHITE PALETTERGB(255,255,255)
// #define NUM_STATIC_COLORS (COLOR_BTNHIGHLIGHT - COLOR_SCROLLBAR + 1)
static void (*ExposeFunc) (int, int) = NULL;
static void (*ReshapeFunc) (GLsizei, GLsizei) = NULL;
static void (*DisplayFunc) (void) = NULL;
static GLenum(*KeyDownFunc) (int, GLenum) = NULL;
static GLenum(*MouseDownFunc) (int, int, GLenum) = NULL;
static GLenum(*MouseUpFunc) (int, int, GLenum) = NULL;
static GLenum(*MouseMoveFunc) (int, int, GLenum) = NULL;
static void (*IdleFunc) (void) = NULL;
#ifdef USE_CLIP_LAYER
/*
* Get from clipping example of the RKM
*/
/*
* clipWindow()
* Clip a window to a specified rectangle (given by upper left and
* lower right corner.) the removed region is returned so that it
* may be re-installed later.
*/
struct Region *clipWindow(struct Window *win,
LONG minX, LONG minY, LONG maxX, LONG maxY)
{
struct Region *new_region;
struct Rectangle my_rectangle;
/*
* set up the limits for the clip
*/
my_rectangle.MinX = minX;
my_rectangle.MinY = minY;
my_rectangle.MaxX = maxX;
my_rectangle.MaxY = maxY;
/*
* get a new region and OR in the limits.
*/
if (NULL != (new_region = NewRegion())) {
if (FALSE == OrRectRegion(new_region, &my_rectangle)) {
DisposeRegion(new_region);
new_region = NULL;
}
}
/*
* Install the new region, and return any existing region.
* If the above allocation and region processing failed, then
* new_region will be NULL and no clip region will be installed.
*/
return (InstallClipRegion(win->WLayer, new_region));
}
/*
* clipWindowToBorders()
* clip a window to its borders.
* The removed region is returned so that it may be re-installed later.
*/
struct Region *clipWindowToBorders(struct Window *win)
{
return (clipWindow(win, win->BorderLeft, win->BorderTop,
win->Width - win->BorderRight - 1, win->Height - win->BorderBottom - 1));
}
#endif
float colorMaps[] = {
0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 1.000000,
0.000000, 1.000000, 0.333333, 0.776471, 0.443137, 0.556863,
0.443137, 0.556863, 0.219608, 0.666667, 0.666667, 0.333333,
0.666667, 0.333333, 0.666667, 0.333333, 0.666667, 0.333333,
0.666667, 0.333333, 0.666667, 0.333333, 0.666667, 0.333333,
0.666667, 0.333333, 0.039216, 0.078431, 0.117647, 0.156863,
0.200000, 0.239216, 0.278431, 0.317647, 0.356863, 0.400000,
0.439216, 0.478431, 0.517647, 0.556863, 0.600000, 0.639216,
0.678431, 0.717647, 0.756863, 0.800000, 0.839216, 0.878431,
0.917647, 0.956863, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.247059, 0.247059,
0.247059, 0.247059, 0.247059, 0.247059, 0.247059, 0.247059,
0.498039, 0.498039, 0.498039, 0.498039, 0.498039, 0.498039,
0.498039, 0.498039, 0.749020, 0.749020, 0.749020, 0.749020,
0.749020, 0.749020, 0.749020, 0.749020, 1.000000, 1.000000,
1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.247059, 0.247059, 0.247059, 0.247059,
0.247059, 0.247059, 0.247059, 0.247059, 0.498039, 0.498039,
0.498039, 0.498039, 0.498039, 0.498039, 0.498039, 0.498039,
0.749020, 0.749020, 0.749020, 0.749020, 0.749020, 0.749020,
0.749020, 0.749020, 1.000000, 1.000000, 1.000000, 1.000000,
1.000000, 1.000000, 1.000000, 1.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.247059, 0.247059, 0.247059, 0.247059, 0.247059, 0.247059,
0.247059, 0.247059, 0.498039, 0.498039, 0.498039, 0.498039,
0.498039, 0.498039, 0.498039, 0.498039, 0.749020, 0.749020,
0.749020, 0.749020, 0.749020, 0.749020, 0.749020, 0.749020,
1.000000, 1.000000, 1.000000, 1.000000, 1.000000, 1.000000,
1.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000,
0.000000, 0.000000, 0.000000, 0.000000, 0.247059, 0.247059,
0.247059, 0.247059, 0.247059, 0.247059, 0.247059, 0.247059